package com.twu.biblioteca;

public class Item {
    protected final String title;
    protected final int year;
    protected User onLoanToUser;

    public Item(String title, int year) {
        this.title = title;
        this.year = year;
        onLoanToUser = null;
    }

    @Override
    public String toString() {
        return title;
    }

    public String getTitle() {
        return title;
    }

    public int getYear() {
        return year;
    }

    public boolean isCheckedOut(){
        return onLoanToUser != null;
    }

    public void checkOut(User user) {
        onLoanToUser = user;
        user.checkOut(this);
    }


}
